#pragma once
#include "xstring.h"
#include <Windows.h>
#include <http.h>

class HttpServer
{
    public:
        HttpServer() = default;
        ~HttpServer();
        HttpServer(const HttpServer&) = delete;
        HttpServer(HttpServer&&) = delete;
        HttpServer& operator=(const HttpServer&) = delete;
        bool init(const wchar_t *url);
        void onReceive(bool &hasExit, HANDLE hProcess);
    private:
        void Do(PHTTP_REQUEST httpReq);
        u8string Index(PHTTP_REQUEST httpReq);
    private:
        bool hasInit = false;
        HANDLE hRequestQueue = nullptr;
        HTTP_SERVER_SESSION_ID sessionId = 0;
        HTTP_URL_GROUP_ID groupId = 0;
};
